home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / env15w.zip / ENV.DOC < prev    next >
Text File  |  1991-10-15  |  15KB  |  415 lines

  1.              ENV - The Master Environment Utility
  2.                          Version 1.5w
  3.  
  4.                               by
  5.  
  6.                          Kjell Eikland
  7.                       674 St. John's Drive
  8.                       Camp Hill, PA 17011
  9.  
  10. -----------------------------------------------------------------
  11.  
  12. ENV is a DOS environment utility which does everything the
  13. internal SET command does, and much more.  If these are new
  14. concepts to you, then you may read quickly through the Appendix
  15. that contains a description of what the environment is and what
  16. the SET command does.  ENV provides:
  17.  
  18. ...  a powerful calculator with a large complement of scientific
  19.      functions, date and time functions (with time zone
  20.      adjustments), and also logical operators.
  21.  
  22. ...  complete text manipulation functions, freely intermixable
  23.      with the mathematical calculation services.
  24.  
  25. ...  interactive editing of existing or new environment
  26.      variables, for example the content of the PATH.
  27.  
  28. ...  automatic prompting for input from the user.
  29.  
  30. ...  testing of environment variables with the result reported in
  31.      DOS's ERRORLEVEL variable.
  32.  
  33. ...  batch commands to speed the execution time and to quickly
  34.      insert new environment variables that may be stored in a
  35.      "library".
  36.  
  37. ...  selective listing and erasure of the environment's content
  38.      based on an extended use of the * and ? wild-cards.
  39.  
  40. ...  a simple report generator to facilitate the development of
  41.      useful routines, such as a DOS command line calculator.
  42.  
  43. ...  report generation to any DOS output file, device or pipe.
  44.  
  45. ...  provides full support for DOS input pipes, such that the DOS
  46.      commands SORT and FIND may be used to dramatically increase
  47.      the possible uses of ENV.
  48.  
  49. ...  free use of any environment present in your computer in
  50.      addition to the standard use of the master DOS environment.
  51.  
  52. ...  status information on the present environment, including the
  53.      owner's name.
  54.  
  55. Licencing information
  56. ---------------------
  57.  
  58. ENV is a Shareware program.  That means you may try it out on
  59. your computer for a limited period of time.  If you find that you
  60. would like to keep ENV on your computer, please send a check for
  61. US$15.00 to the address given on the first page.
  62.  
  63.  
  64.      ENV is written and copyrighted by Kjell Eikland 1991.
  65.  
  66.  
  67.  
  68.                       ----------------
  69.  
  70.  
  71.  
  72.       Feedback welcome through Compuserve (CIS) 72461,556
  73.  
  74.  
  75. Using ENV
  76.  
  77.  
  78. General syntax
  79. --------------
  80.  
  81. ENV uses the following command structure:
  82.  
  83.      ENV [general command] [specific action]
  84.  
  85.  
  86. The general commands are:
  87.  
  88.      HELP           Provide help for ENV
  89.      STATUS         Show environment usage
  90.      LIST           Display the content of the environment
  91.      EDIT           Do interactive editing of a variable
  92.      ERASE          Erase one or more variables
  93.      EXIST          Test for the existence of a variable
  94.      CALC           Compute the value of a text or mathematical
  95.                     expression
  96.      ASK            Interactively ask to define an environment
  97.                     variable
  98.      SET            Define the content of a variable
  99.      SET%           As SET but add a leading and trailing %
  100.      TEST           Test for equality
  101.  
  102.  
  103. In its simplest form a mathematical calculation could be
  104. performed by writing:
  105.  
  106.      ENV SET TEST=(1+2)/3
  107.      ENV CALC TEST
  108.      ENV LIST TEST
  109.      ENV ERASE TEST
  110.  
  111.  
  112. (Of course, this is better implemented in an ENV batch file so
  113. that DOS does not have to reload ENV every time.)  Similarly, a
  114. simple text expression could be written:
  115.  
  116.      ENV SET TEST=a+b+c+d+MID(efgh~2~2)
  117.      etc.
  118.  
  119.  
  120. or with variable substitution:
  121.  
  122.      ENV SET TEST=MID(%COMSPEC%~3~LENGTH(%COMSPEC%)-2)
  123.      etc.
  124.  
  125.  
  126. Using redirection and piping
  127. ----------------------------
  128.  
  129. ENV supports redirection and piping for all of the relevant
  130. commands.  For example, the current directory may be retrieved by
  131. writing:
  132.  
  133.      CD|ENV SET CURDIR
  134.  
  135.  
  136. The environment may be sorted, saved and restored with the
  137. commands:
  138.  
  139.      ENV LIST * SET {GET*NAME}={GET*VALUE}|SORT >ENVSAVE.TMP
  140.      ENV ERASE *
  141.      ENV BATCH <ENVSAVE.TMP
  142.  
  143.  
  144. Similarly, a sorted listing of the environment may be printed by
  145. writing:
  146.  
  147.      ENV LIST *|SORT >PRN
  148.  
  149.  
  150. If you wish to store the version of the operating system in an
  151. environment variable you would type:
  152.  
  153.      VER|FIND "Version"|ENV SET DOSVERSION
  154.  
  155.  
  156. These are only some of the possible uses of redirection and
  157. piping.  Particularly together with DOS's FIND and type
  158. utilities, as well as the enhanced ability of DOS 5.0 of scan
  159. subdirectories, there is effectively no limit to the possible
  160. uses of redirection and piping in ENV.
  161.  
  162.  
  163. The use of wild-cards
  164. ---------------------
  165.  
  166. In certain situations, it is convenient or necessary to specify
  167. more than one environment variable in one statement.  In DOS, a
  168. similar situation arises when you wish to have a directory
  169. listing of more than one file - say of all files whose names
  170. begin with the letter A.  You would then type "DIR A*.*".  If the
  171. files of interest have names with three letters you would type
  172. "DIR ???.*".  DOS uses the character "*" to signify any character
  173. or many characters.  "?" signifies a character.  Collectively,
  174. "*" and "?" are called wild-cards.
  175.  
  176. The big problem with DOS's use of wild-cards wildcards is that
  177. "*" may not be followed by a letter.  That means that it is
  178. impossible to have DOS list all files that end with an "E"; i.e.
  179. the command "DIR *E.*" is incomprehensible to DOS.
  180.  
  181. With this introduction it is fairly obvious that ENV handles full
  182. wild-card usage.  Thus, if you wish to list all variables ending
  183. with an "E" followed by two other letters you would write
  184. "ENV LIST *E??".  Both the ENV LIST and ENV ERASE commands use
  185. this syntax.
  186.  
  187. Additionally, in the case of piped input (consult the section on
  188. "Using DOS pipes and files with ENV" if this concept is new to
  189. you) to the ENV SET command an entire file or listing may be
  190. loaded into the environment with numbered lines.  Two examples of
  191. this usage:
  192.  
  193.      DIR|SORT|ENV SET FILE*        This would load the
  194.                                    environment with the names of
  195.                                    all files in the current
  196.                                    directory sorted
  197.                                    alphabetically, and given the
  198.                                    names FILE001, FILE002, etc.
  199.  
  200.      TYPE CONFIG.SYS|ENV SET CFG*  This would load the
  201.                                    environment with all lines in
  202.                                    the CONFIG.SYS file, numbered
  203.                                    consequtively.
  204.  
  205. Calculator operators and functions
  206. ----------------------------------
  207.  
  208. Math:
  209.  
  210.      Operators           Functions              1/0 Logic
  211.  
  212.   +  Addition            LN(■Number■)        >  Greater than
  213.   -  Subtraction         EXP(■Number■)       <  Less than
  214.   *  Multiplication      INT(■Number■)       ≡  Equal to
  215.   /  Division            FLOOR(■Number■)     ≥  GT or EQ to
  216.   ^  Exponentiation      SIN(■Number■)       ≤  LT or EQ to
  217.   √  n'th root           ASIN(■Number■)
  218.   @  Modulo/remainder    LRAND(■Number■)
  219.   ÷  Integer division    NRAND(■Number■)
  220.                          !(■Number■)
  221.                          GAMMA(■Number■)
  222.                          CUMNORM(■Number■)
  223.                          PI()
  224.  
  225.  
  226. In addition to the SIN/ASIN functions, COS/ACOS and TAN/ATAN are
  227. similarly defined.  All trigonometric functions use radians.
  228.  
  229.  
  230. Date:
  231.  
  232.   TIMENOW(■Time Zone Offset■)      Current time in HH.MMSS format
  233.   DATENOW(■Time Zone Offset■)      Current date in YYYY.MMDD
  234.                                    format
  235.   DECTIME(■HMS time number■)       Convert time to decimal format
  236.   HMSTIME(■DEC time number■)       Convert time to HMS format
  237.   DAYS(■YYYY.MMDD day number■)     Days since 15 Oct.1582 serial
  238.                                    number
  239.   YMD(■Date serial number■)        Convert serial date to
  240.                                    YYYY.MMDD format
  241.  
  242. As an example, the expression DAYS(DATENOW())-DAYS(1918.1111)
  243. would give the number of days since 11 november 1918.  The
  244. expression DATENOW(-3) would give the date in current time zone
  245. less 3 hours.
  246.  
  247.  
  248. Text:
  249.  
  250.   LENGTH(■String■)                           Length of a string
  251.   POS(■Target■~■String■)                     Position of a
  252.                                              substring
  253.   MID(■String■~■StartPos■~■Chars■)           Extract a substring
  254.   INSERT(■AddString■~■String■~■StartPos■)    Insert a string into
  255.                                              a string
  256.   DELETE(■String■~■StartPos■~■Count■)        Delete characters in
  257.                                              a string
  258.   UCASE(■String■)                            Convert string to
  259.                                              upper case
  260.   LCASE(■String■)                            Convert string to
  261.                                              lower case
  262.   ASC(■Character■)                           ASCII value of a
  263.                                              character
  264.   CHR(■AsciiValue■)                          Character of an
  265.                                              ASCII code
  266.   COPY(■Character■~■Count■)                  Replicate a
  267.                                              character
  268.  
  269.  
  270. The expression MID(%COMSPEC%~1~2) would give the disk drive where
  271. command processor COMMAND.COM is located.  The expression 
  272. COPY(CHR(205)~LENGTH(%PATH%)) would create a string of ═'s with a
  273. lenght equal to the current length of the PATH variable.
  274.  
  275.  
  276. Internal:
  277.  
  278.   {ENV*OWNER}       Get the owner of the current environment
  279.   {ENV*SIZE}        Retrieve the total size of the environment
  280.   {ENV*USED}        Compute bytes currently used in the
  281.                     environment
  282.   {ENV*COUNT}       Total the current number of variables defined
  283.   {GET*DRIVE}       Obtain the default/current disk drive
  284.   {GET*DIR}         Obtain the default/current directory
  285.   {GET*NAME}        Return the name of the currently active
  286.                     variable
  287.   {GET*VALUE}       Return the value of the currently active
  288.                     variable
  289.  
  290.  
  291. Accessing other than the master environment
  292. -------------------------------------------
  293.  
  294. Any environment may be accessed by defining ENVLEVEL=■n■ in the
  295. master environment, where ■n■ is an integer specifying the loaded
  296. order of the desired program.  The master environment may always
  297. be accessed by ENV MASTER ■EnvCommand■.
  298.  
  299. By issuing the ENV STATUS command the name of owner of the
  300. current environment will be displayed.
  301.  
  302. Appendix
  303. The in's and out's of the SET command 
  304.  
  305. SET is an internal DOS command which adds, changes or deletes
  306. elements in the command processor's environment.  Being an
  307. internal command, you will not see a SET.COM or SET.EXE file in
  308. any directory listing.  The command processor is the program that
  309. gives you the DOS prompt (i.e. A> or C>) where you can issue DOS
  310. commands and start programs.  Normally the command processor is a
  311. file with the name COMMAND.COM.
  312.  
  313. The command processor (and all programs) have reserved a portion
  314. of memory to store parameters that are necessary for the
  315. execution of the program, or simply useful.  This area of memory
  316. is called the "environment".  The command processor's environment
  317. is called the "master environment" because it is the first
  318. created and one that is always there as long as your computer is
  319. turned on. 
  320.  
  321. The master environment always contains two elements, namely
  322. COMSPEC and PATH.  In the simplest setup possible for your
  323. computer these two elements have the values:
  324.  
  325.      PATH=
  326.      COMSPEC=A:\COMMAND.COM
  327.  
  328. You may see the content of your master environment by typing SET
  329. from the DOS prompt.
  330.  
  331. COMSPEC identifies where a program may find the command processor
  332. and what it is called.  In some installations the command
  333. processor may have the name 4DOS.COM.  PATH identifies where DOS
  334. should look for programs when the program is not located in the
  335. present directory.  The peculiar thing about PATH is that it may
  336. contain nothing (nothing to the right of the =-sign).  Any other
  337. relationship is removed if it doesn't contain anything.
  338.  
  339. Another standard element in the master environment is PROMPT.  By
  340. adding PROMPT to your environment you can change the way the
  341. command processor prompts you for a command.  If you type:
  342.  
  343.      SET PROMPT=$P$G 
  344.  
  345. the prompt would, for example, look like "A:\DATA>".  Other
  346. values for PROMPT are described in your DOS manual.  By typing
  347. SET, your environment would now contain:
  348.  
  349.      PATH= 
  350.      COMSPEC=A:\COMMAND.COM 
  351.      PROMPT=$P$G 
  352.  
  353. Please note the capitalization rules here.  The identifier or
  354. name of the variable (e.g. PATH or COMSPEC) are always
  355. capitalized regardless how you typed them.  The value on the
  356. right hand side, however, will be copied as you type it.  The
  357. general format for using the SET command is then: 
  358.  
  359.      SET                      List all entries in the
  360.                               environment.
  361.  
  362.      SET <Name>=<Value>       Define a new or replace an
  363.                               existing relationship.
  364.  
  365.      SET <Name>=              Remove an entry in the
  366.                               environment.
  367.  
  368.  
  369. Generally, these possible usage options are summarized by:
  370.  
  371.      SET [<Name>=[<Value>]]
  372.  
  373.  
  374. where the square brackets indicate a user option.  <Value> may be
  375. any combination of valid letters and characters, but can also
  376. contain environment variables!  Now, how can you as a user make
  377. use of environment variables?  Some programs require that you
  378. define certain environment variables, but because of DOS's rather
  379. rudimentary batch command language and the limited capabilities
  380. of the SET command the usefulness is relatively limited.
  381.  
  382. By enclosing the variable name between %-signs in a batch file
  383. the value of that variable will be substituted.  Many variables
  384. may be substituted on the same line.  For example, consider the
  385. following segment of a batch file: 
  386.  
  387.      SET OLDPATH=%PATH%
  388.      SET PATH=C:\
  389.      ECHO Starting a secondary command processor
  390.      ECHO I'm using %COMSPEC% with the path %PATH%
  391.      %COMSPEC% /E:512
  392.      SET PATH=%OLDPATH%
  393.      SET OLDPATH=
  394.  
  395.  
  396. The default size of the environment is between 128 and 180 bytes,
  397. depending on the DOS version.  You may specify a larger
  398. environment using the SHELL command in the CONFIG.SYS setup file
  399. (see your DOS manual).  The maximum size of the environment is
  400. 32 kilobytes in DOS 3.2 and higher; enough for most purposes.
  401.  
  402. But every time you start a program, DOS will create a new (child)
  403. environment for that program, leaving the command processor's
  404. environment in the dust.  All unused space will be eliminated in
  405. the child environment.  That means that the program essentially
  406. receives a "dead-end" environment.  In a multi-tasking world,
  407. such as under Windows or DesqView, programs cannot communicate
  408. through their respective environments.  Windows even uses two
  409. environments at the same time, neither of any use for the normal
  410. user since they have been truncated and not easily accessible by
  411. other programs or the SET command!
  412.  
  413. ... until the appearance of ENV!
  414.  
  415.